 <!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>缓存服务配置工具-字段</title>
    <!-- 新 Bootstrap 核心 CSS 文件  -->
    <link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/bootstrap-table.css">
    <link rel="stylesheet" type="text/css" href="../css/common.css">
    <link rel="stylesheet" type="text/css" href="../css/manage.css">
    <link rel="stylesheet" type="text/css" href="../css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../layer/skin/layer.css">
</head>
<body>
<div class="wrap animated fadeInRight pd-40">


    <h3 class="zh_title blod500">字段</h3>
    <div class="row manage_btn">
        <div class="col-sm-12">
            <button class="blue" id="newzh">新增</button>
        </div>
    </div>

    <div class="row manage_tb">
        <table  cellpadding="0" cellspacing="0" id="demo-table">
        </table>
    </div>


</div>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<!-- 滚动条- -->
<script type="text/javascript" src="../js/bootstrap-table.js"></script>
<script type="text/javascript" src="../js/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="../js/Jquery.ETTool-1.0.js"></script>
<script type="text/javascript" src="../layer/layer.js"></script>

<script type="text/javascript">
    localStorage.setItem("arrgunsTHF","")
    function linkTo(x){
        localStorage.setItem("fieldCode",x);
    }
    function add(){
        localStorage.setItem("edit","")
        parent.layer.open({
            type: 2,
            skin: 'layui-layer-gray',
            title: ['新增字段','font-size:20px;text-align:center;color:#424f62;font-weight:bolder'],
            scrollbar:false,
            area: ['900px', '430px'],
            //offset: [top, '253px'],
            shift: 2 ,
            content: '字段修改.html',
            success:function(index){

            }
        })
    }
    //    新增
    $("#newzh").click(function(){
        add()
    })
    function edit(x){
        localStorage.setItem("fieldCode",arguments[0].split(",")[0])
        localStorage.setItem("arrgunsTHF",arguments[0])
        localStorage.setItem("edit","true")

        parent.layer.open({
            type: 2,
            skin: 'layui-layer-gray',
            title: ['修改字段','font-size:20px;text-align:center;color:#424f62;font-weight:bolder'],
            scrollbar:false,
            area: ['900px', '430px'],
            //offset: [top, '253px'],
            shift: 2 ,
            content: '字段修改.html',
            success:function(index){

            }
        })
    }
    function deleteX(x){
        var C = localStorage.getItem('appCode')
        var url = 'http://10.238.119.7:8080/apps/'+localStorage.getItem('appCode')+'/resources/'+localStorage.getItem('resourceCode')+'/definitions/'+localStorage.getItem("definitionCode") +'/fields/' + x;
        $.ajax({
            url: url,
            async: false,//
            method: 'DELETE',//PUT DELETE POST
//            contentType:"application/x-www-form-urlencoded",
            dataType:'text',
            success: function (result) {
                if(result == ""){
                    layer.msg("删除成功")
                    setTimeout(function(){
                        window.location.reload()
                    },500)
                }else{
                    layer.msg(result.collection.error.message )
                }
            console.log(result)

            }
        })
    }
        $(function () {
            var url = 'http://10.238.119.7:8080/apps/'+localStorage.getItem('appCode')+'/resources/'+localStorage.getItem('resourceCode')+'/definitions/'+localStorage.getItem("definitionCode") +'/fields';
            $.ajax({
                url: url,
                async: true,//
                type: 'GET',//PUT DELETE POST
                success: function (result) {
                    var data = $.ET.toObjectArr(result)
                    if(data ==""){
                        add()
                    }
                    initTable(data)
                }
            })
        });
        function initTable(data){
            $('#demo-table').bootstrapTable({
                data:data,
                pagination: true, //启动分页
                pageSize: 10,  //每页显示的记录数
                pageNumber:1, //当前第几页
                columns: [
                    {
                        field: '',
                        title: '序号',
                        formatter: function (value, row, index) {
                            return index+1;
                        }
                    },
                    {
                        field : 'definitionId',
                        title : '定义ID',
                        align : 'center',
                        valign : 'middle',
                        sortable : true
                    },{
                        field : 'fieldCode',
                        title : '字段编码',
                        align : 'center',
                        valign : 'middle'
                    },{
                        field : 'fieldName',
                        title : '字段名称',
                        align : 'center',
                        valign : 'middle'
                    }, {
                        field : 'crtUserName',
                        title : '创建人',
                        align : 'center',
                        valign : 'middle',
                        sortable : true
                    },{
                        field : 'crtDate',
                        title : '创建日期',
                        align : 'center',
                        valign : 'middle',
                        sortable : true
                    },{
                        field : 'mntUserName',
                        title : '最后维护人',
                        align : 'center',
                        valign : 'left'
                    }, {
                        field : 'mntDate',
                        title : '最后维护日期',
                        align : 'center',
                        valign : 'middle'
                    }, {
                        field : 'des',
                        title : '描述',
                        align : 'center',
                        valign : 'middle'
                    } , {
                        field : 'sortNum',
                        title : '排序',
                        align : 'center',
                        valign : 'middle'
                    },{
                        field : 'resourceCode',
                        title : '操作',
                        align : 'center',
                        valign : 'middle',
                        formatter:function(value,row,index){
                            var e = '<a href="#" mce_href="#" onclick="edit(\''+ row.fieldCode + ','+row.fieldCode+','+row.fieldName+','+row.crtUserId+','+row.crtUserName+ ','+row.mntUserId+ ','+row.mntUserName+','+row.des+ '\')">修改</a> ';
                            var d = '<a href="#" mce_href="#" onclick="deleteX(\''+ row.fieldCode + '\')">删除</a> ';
                            return e+d;
                        }
                    }]
            });
        }

</script>

</body>
</html>

